<template>
  <div class="dialog_handicap">
    <div
      class="handicap_button1 DINAlternate"
      :class="
        data.activeodds.findIndex(item2 => item2.pk_ratio == item.pk_ratio) != -1
          ? 'handicap_button1_active'
          : ''
      "
      v-for="(item, index) in data.data"
      @click="dialogStore.addactiveodds(item.pk_ratio, dataindex)"
      :key="index"
    >
      <!-- data.pk_ratio >= 0 ? item.pk_ratio : -item.pk_ratio -->
      {{ getHandicap(item.odds[data.pkindex].pk_odds_key) }}
      <!-- {{ item.odds[data.pkindex].odds_name }} -->
    </div>
  </div>
</template>

<script setup>
import { onMounted } from 'vue'

const props = defineProps({
  data: Object,
  dataindex: Number,
})
const { dialogStore, dialogState } = inject('DialogStore')
const languageJson = inject('languageJson')
const languageType = inject('languageType')
const clickadd = () => {
  props.data.data.push('1')
}

const getlabel = item => {
  console.log(item)
  console.log(props.data)

  return ''
}

const getHandicap = pk_odds_key => {
  console.log(pk_odds_key)
  let pkoddskeyarr = pk_odds_key.split(':')
  let str = ''
  if (pkoddskeyarr[1] != 'M') {
    str = pkoddskeyarr[pkoddskeyarr.length - 2]
  } else {
    if (pkoddskeyarr[3] == '0') {
      str = `${languageJson.value.home.home}${languageJson.value.home.win}`
    }
    if (pkoddskeyarr[3] == '1') {
      str = `${languageJson.value.home.away}${languageJson.value.home.win}`
    }
    if (pkoddskeyarr[3] == '2') {
      str = languageJson.value.home.draw
    }
  }
  return str
}
</script>

<style lang="scss" scoped>
.dialog_handicap {
  margin: 0 0 12px 12px;
  width: 74px;
  display: flex;
  flex-direction: column;
}
.handicap_button1 {
  width: 74px;
  height: 24px;
  line-height: 24px;
  text-align: center;

  font-size: 12px;
  font-weight: bold;

  margin-bottom: 2px;
  cursor: pointer;
  color: #666;
  background-color: #f3f5fd;
}
.handicap_button1_active {
  background-color: #d5daff;
  color: #3711d8;
}

.handicap_button_item {
  display: flex;
  margin-bottom: 2px;
}
.handicap_button2 {
  width: 36px;
  height: 24px;
  line-height: 24px;
  background-color: #f3f5fd;
  font-size: 12px;
  font-weight: bold;
  text-align: center;
  color: #666;
  cursor: pointer;
}
</style>